home *** CD-ROM | disk | FTP | other *** search
/ Champak 138 / Volume 138 Aug 19 2011 - Damaged.iso / Games / shadez.swf / scripts / Local / Game / Thing / CAircraftApache.as < prev    next >
Encoding:
Text File  |  2011-08-19  |  11.2 KB  |  433 lines

  1. package Local.Game.Thing
  2. {
  3.    import Local.Game.World.*;
  4.    import Local.Game.World.Map.*;
  5.    import Local.Game.World.Map.Cell.*;
  6.    import Local.Math.*;
  7.    import STC9.System.*;
  8.    import flash.display.*;
  9.    import flash.events.*;
  10.    import flash.geom.*;
  11.    
  12.    public class CAircraftApache extends CAircraft
  13.    {
  14.        
  15.       
  16.       private var mAltitude:Number;
  17.       
  18.       private var mMinAltitude:Number;
  19.       
  20.       private var mHellFire:CWeaponHellFire;
  21.       
  22.       private var mRearRotor:CThingAnimation;
  23.       
  24.       private var mMaxAltitude:Number;
  25.       
  26.       private var mMainGun:CWeaponGunApache;
  27.       
  28.       private var mTrackSoundID:String;
  29.       
  30.       private var mMainRotor:CThingAnimation;
  31.       
  32.       private var _Command:String = "proceed";
  33.       
  34.       public function CAircraftApache(param1:CPosition)
  35.       {
  36.          _Command = "proceed";
  37.          super(param1);
  38.          mType = "apache";
  39.          Process = Process_Normal;
  40.          mMaxLife = mLife = 200;
  41.          ┬º┬ºpush(┬º┬ºfindproperty(mMaxSpeed));
  42.          ┬º┬ºpush(9 + Math.random() * 2);
  43.          if(true)
  44.          {
  45.             ┬º┬ºpush(┬º┬ºpop() * mSpriteScalar);
  46.          }
  47.          ┬º┬ºpop().mMaxSpeed = ┬º┬ºpop();
  48.          mSpeed = 0;
  49.          mAcceleration = 0.6;
  50.          mOrientation = 1;
  51.          mDelta = new CPosition(0,0);
  52.          AddThing(mHellFire = new CWeaponHellFire());
  53.          AddThing(mMainRotor = new CThingAnimation(Apache_MainRotor));
  54.          AddThing(mRearRotor = new CThingAnimation(Apache_RearRotor));
  55.          mWeaponDelta = new CPosition();
  56.          mMaxAltitude = mAltitude = 140;
  57.          mMinAltitude = 80;
  58.          AddAnimation("stand",Apache,"AddSprite_Scale");
  59.          SetCollisionBySprite(mAnimation[0]);
  60.          AddLoopingSound("flight",Apache_Move);
  61.          mTrackSoundID = PlaySound("flight");
  62.          IncrementBuild();
  63.          SetTargetting(1150 - Math.random() * 300,true,FILTER_AnyTarget,true,100);
  64.          SetState("GOTO");
  65.       }
  66.       
  67.       public static function get mCost() : int
  68.       {
  69.          return 25000;
  70.       }
  71.       
  72.       public function get mIconIndex() : int
  73.       {
  74.          return 3;
  75.       }
  76.       
  77.       override public function Dispose() : void
  78.       {
  79.          if(true)
  80.          {
  81.             if(mDisposed)
  82.             {
  83.                if(true)
  84.                {
  85.                   return;
  86.                }
  87.             }
  88.             else
  89.             {
  90.                super.Dispose();
  91.             }
  92.             StopSound(mTrackSoundID);
  93.          }
  94.       }
  95.       
  96.       public function State_MOUSEOVER_Enter() : void
  97.       {
  98.       }
  99.       
  100.       public function get mCommandDrop() : Boolean
  101.       {
  102.          return false;
  103.       }
  104.       
  105.       public function get mCommand() : String
  106.       {
  107.          return _Command;
  108.       }
  109.       
  110.       public function set mCommand(param1:String) : void
  111.       {
  112.          _Command = param1;
  113.          if(_Command == "proceed")
  114.          {
  115.             mSpeed = 0;
  116.          }
  117.       }
  118.       
  119.       private function _targetThing() : CThingMain
  120.       {
  121.          if(true)
  122.          {
  123.             if((mCurrentTarget = GetTarget()) != null)
  124.             {
  125.                if(true)
  126.                {
  127.                   ┬º┬ºpush(!mCurrentTarget.mTargetAirbourne);
  128.                   ┬º┬ºpush(!mCurrentTarget.mTargetAirbourne);
  129.                   if(true)
  130.                   {
  131.                      if(┬º┬ºpop())
  132.                      {
  133.                         ┬º┬ºpop();
  134.                         if(true)
  135.                         {
  136.                            addr45:
  137.                            if(!(GetTargetRange(mCurrentTarget) < 650 || mCurrentTarget.mTargetAirbourne))
  138.                            {
  139.                               mCurrentTarget = null;
  140.                            }
  141.                            ┬º┬ºgoto(addr66);
  142.                         }
  143.                         SetState("TARGETAIR");
  144.                         ┬º┬ºgoto(addr55);
  145.                      }
  146.                   }
  147.                   ┬º┬ºgoto(addr45);
  148.                }
  149.                addr55:
  150.                ┬º┬ºgoto(addr66);
  151.             }
  152.          }
  153.          addr66:
  154.          return mCurrentTarget;
  155.       }
  156.       
  157.       public function State_GOTO_Exit() : void
  158.       {
  159.       }
  160.       
  161.       public function GetShotDelta(param1:String) : CPosition
  162.       {
  163.          return mWeaponDelta.Clone();
  164.       }
  165.       
  166.       public function State_TARGETGROUND_Exit() : void
  167.       {
  168.          if(true)
  169.          {
  170.             ┬º┬ºpush(mMainGun);
  171.             if(true)
  172.             {
  173.                ┬º┬ºpop().mFire = false;
  174.                ┬º┬ºpush(mMainGun);
  175.             }
  176.             ┬º┬ºpop().mCurrentTarget = null;
  177.          }
  178.       }
  179.       
  180.       public function State_MOUSEOVER_Exit() : void
  181.       {
  182.       }
  183.       
  184.       public function State_GOTO() : void
  185.       {
  186.          var _loc1_:* = NaN;
  187.          if(true)
  188.          {
  189.             _targetThing();
  190.             if(true)
  191.             {
  192.                if(_Command == "proceed")
  193.                {
  194.                   if(true)
  195.                   {
  196.                      mAngle.mAngle256 = mDelta.length / mMaxSpeed * 2;
  197.                      if(true)
  198.                      {
  199.                         Accelerate_Gradient(mDelta,mGradient);
  200.                         if(true)
  201.                         {
  202.                            mPosition.Add(mDelta);
  203.                            if(true)
  204.                            {
  205.                               ┬º┬ºpush(mAltitude);
  206.                               if(true)
  207.                               {
  208.                                  ┬º┬ºpush(┬º┬ºpop() / 2);
  209.                               }
  210.                               _loc1_ = ┬º┬ºpop();
  211.                            }
  212.                            mPosition.y = (GetAltitude(mPosition.x - _loc1_) + GetAltitude(mPosition.x + _loc1_)) / 2 - mAltitude;
  213.                         }
  214.                         if(MapMove())
  215.                         {
  216.                         }
  217.                         mCollide.Update();
  218.                         addr90:
  219.                         if(mDisposed)
  220.                         {
  221.                            ┬º┬ºgoto(addr92);
  222.                         }
  223.                         else
  224.                         {
  225.                            return;
  226.                         }
  227.                         addr81:
  228.                      }
  229.                      Process_ReachedObjective();
  230.                   }
  231.                   ┬º┬ºgoto(addr81);
  232.                }
  233.             }
  234.             ┬º┬ºgoto(addr90);
  235.          }
  236.          addr92:
  237.       }
  238.       
  239.       public function State_WAIT() : void
  240.       {
  241.          if(true)
  242.          {
  243.             if(_targetThing() != null)
  244.             {
  245.                if(true)
  246.                {
  247.                   return;
  248.                }
  249.                addr28:
  250.                SetState("GOTO");
  251.             }
  252.             else if(mStateCount < 0)
  253.             {
  254.                ┬º┬ºgoto(addr28);
  255.             }
  256.          }
  257.       }
  258.       
  259.       public function State_MOUSEOVER() : void
  260.       {
  261.          if(true)
  262.          {
  263.             ┬º┬ºpush(mStateCount < 0);
  264.             if(true)
  265.             {
  266.                if(┬º┬ºpop())
  267.                {
  268.                   ┬º┬ºpop();
  269.                   if(true)
  270.                   {
  271.                      addr30:
  272.                      if(mMouseOver)
  273.                      {
  274.                      }
  275.                      ┬º┬ºgoto(addr34);
  276.                   }
  277.                   SetState(mReturnStateID);
  278.                   addr34:
  279.                   return;
  280.                }
  281.             }
  282.          }
  283.          ┬º┬ºgoto(addr30);
  284.       }
  285.       
  286.       public function State_TARGETGROUND_Enter() : void
  287.       {
  288.       }
  289.       
  290.       public function get mLongName() : String
  291.       {
  292.          return "APACHE ATTACK HELICOPTER";
  293.       }
  294.       
  295.       public function get mCommandProceed() : Boolean
  296.       {
  297.          return true;
  298.       }
  299.       
  300.       public function State_TARGETAIR_Enter() : void
  301.       {
  302.       }
  303.       
  304.       public function get mShortDesc() : String
  305.       {
  306.          return "The Apache Helicopter equipped with hellfire radar guided missiles and a 30mm chain gun under the nose. Ok against ground units and great against air units!";
  307.       }
  308.       
  309.       public function State_TARGETAIR_Exit() : void
  310.       {
  311.          mHellFire.mFire = false;
  312.          mHellFire.mCurrentTarget = null;
  313.       }
  314.       
  315.       public function State_TARGETGROUND() : void
  316.       {
  317.          if(!ValidTarget(mCurrentTarget))
  318.          {
  319.             SetState("GOTO");
  320.             return;
  321.          }
  322.          ┬º┬ºpush(mMainGun);
  323.          if(true)
  324.          {
  325.             ┬º┬ºpop().mCurrentTarget = mCurrentTarget;
  326.             ┬º┬ºpush(mMainGun);
  327.          }
  328.          ┬º┬ºpop().mFire = true;
  329.       }
  330.       
  331.       public function State_GOTO_Enter() : void
  332.       {
  333.          if(true)
  334.          {
  335.             mSpeed = 0;
  336.          }
  337.       }
  338.       
  339.       override public function Draw() : void
  340.       {
  341.          var _loc1_:Matrix = null;
  342.          var _loc2_:Point = null;
  343.          super.Draw();
  344.          _loc1_ = GetOrientationMatrix();
  345.          if(true)
  346.          {
  347.             DrawSprite(_loc1_);
  348.          }
  349.          _loc2_ = _loc1_.transformPoint(mSprite.mObjects["mainrotor"].mPosition);
  350.          ┬º┬ºpush(mMainRotor);
  351.          if(true)
  352.          {
  353.             ┬º┬ºpop().mPosition.SetXY(_loc2_.x + mPosition.x,_loc2_.y + mPosition.y);
  354.             ┬º┬ºpush(mMainRotor);
  355.          }
  356.          ┬º┬ºpop().Draw();
  357.          _loc2_ = _loc1_.transformPoint(mSprite.mObjects["rearrotor"].mPosition);
  358.          if(true)
  359.          {
  360.             mRearRotor.mPosition.SetXY(_loc2_.x + mPosition.x,_loc2_.y + mPosition.y);
  361.             mRearRotor.Draw();
  362.          }
  363.       }
  364.       
  365.       public function State_WAIT_Exit() : void
  366.       {
  367.       }
  368.       
  369.       public function Process_Normal() : void
  370.       {
  371.          if(Process_State != null)
  372.          {
  373.             Process_State();
  374.          }
  375.          if(mDisposed)
  376.          {
  377.             return;
  378.          }
  379.          mHellFire.mPosition.Copy(GetObjectPosition("hellfire",mPosition));
  380.          Process_Children();
  381.          if(mDead)
  382.          {
  383.             DispatchDispose();
  384.          }
  385.       }
  386.       
  387.       public function get mCommandHalt() : Boolean
  388.       {
  389.          return true;
  390.       }
  391.       
  392.       override public function get mSmallPrize() : int
  393.       {
  394.          return mCost;
  395.       }
  396.       
  397.       override public function get mPrize() : int
  398.       {
  399.          return mCost * 2;
  400.       }
  401.       
  402.       public function State_TARGETAIR() : void
  403.       {
  404.          if(!ValidTarget(mCurrentTarget))
  405.          {
  406.             mStateCount = SECONDS;
  407.             SetState("WAIT");
  408.             return;
  409.          }
  410.          ┬º┬ºpush(mHellFire);
  411.          if(true)
  412.          {
  413.             ┬º┬ºpop().mCurrentTarget = mCurrentTarget;
  414.             ┬º┬ºpush(mHellFire);
  415.          }
  416.          ┬º┬ºpop().mFire = true;
  417.       }
  418.       
  419.       public function get mCommandTakeControl() : Boolean
  420.       {
  421.          return false;
  422.       }
  423.       
  424.       public function State_WAIT_Enter() : void
  425.       {
  426.          if(true)
  427.          {
  428.             mSpeed = 0;
  429.          }
  430.       }
  431.    }
  432. }
  433.